package cn.teduymdj.jxc.preload;


import cn.teduymdj.jxc.service.GoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class CachePreload implements ApplicationRunner {

    @Autowired
    private GoodsService goodsService;

    public CachePreload() {
        log.debug("创建开机自动执行的组件对象：CachePreload");
    }


    // ApplicationRunner中的run()方法会在项目启动成功之后自动执行
    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.debug("CachePreload.run()");
        goodsService.rebuildCache();
        log.debug("本次计划任务执行完成");
    }

}
